﻿Imports DotNetNuke
Imports DotNetNuke.Common
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Entities.Tabs
Imports DotNetNuke.Entities.Portals
Imports DotNetNuke.Security.Permissions
Imports Disgrafic.Modules.Sitemap
Imports System.Web
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Modules.Blog.Business

Public Class DNNBlogSitemapProvider
	Inherits Disgrafic.Modules.Sitemap.SitemapProvider

	Private useLevelBasedPagePriority As Boolean
	Private minPagePriority As Single
	Private includeHiddenPages As Boolean

	''' <summary>
	''' Includes page urls on the sitemap
	''' </summary>
	''' <remarks>
	''' Pages that are included:
	''' - are not deleted
	''' - are not disabled
	''' - are normal pages (not links,...)
	''' - are visible (based on date and permissions)
	''' </remarks>
	Public Overrides Function GetUrls(ByVal portalId As Integer, ByVal ps As PortalSettings, ByVal version As String) As List(Of SitemapUrl)

		Dim blogUrl As SitemapUrl
		Dim urls As New List(Of SitemapUrl)

		Dim blog As New EntryController
		Dim entries As ArrayList = blog.ListAllEntriesByPortal(portalId, False, False)

		For Each entry As EntryInfo In entries
			blogUrl = GetBlogUrl(entry, ps.PortalAlias.HTTPAlias)
			urls.Add(blogUrl)
		Next
		Return urls
	End Function

	Private Function GetBlogUrl(ByVal objEntry As EntryInfo, ByVal portalAlias As String) As SitemapUrl

		Dim pageUrl As New SitemapUrl
		pageUrl.Url = objEntry.PermaLink
		pageUrl.Priority = 0.5
		pageUrl.LastModified = objEntry.AddedDate
		pageUrl.ChangeFrequency = SitemapChangeFrequency.Weekly

		Return pageUrl
	End Function
End Class
